home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Python 1.4 / Python 1.4 source / Mac / scripts / FixCreator.py < prev    next >
Encoding:
Python Source  |  1996-09-16  |  685 b   |  37 lines  |  [TEXT/Pyth]

  1. #
  2. # FixCreator - Search for files with PYTH creator
  3. # and set it to Pyth.
  4. #
  5. import os
  6. import macfs
  7. import sys
  8. import macostools
  9.  
  10. OLD='PYTH'
  11. NEW='Pyth'
  12.  
  13. def walktree(name, change):
  14.     if os.path.isfile(name):
  15.         fs = macfs.FSSpec(name)
  16.         cur_cr, cur_tp = fs.GetCreatorType()
  17.         if cur_cr == OLD:
  18.             fs.SetCreatorType(NEW, cur_tp)
  19.             macostools.touched(fs)
  20.             print 'Fixed ', name
  21.     elif os.path.isdir(name):
  22.         print '->', name
  23.         files = os.listdir(name)
  24.         for f in files:
  25.             walktree(os.path.join(name, f), change)
  26.             
  27. def run(change):
  28.     fss, ok = macfs.GetDirectory('Folder to search:')
  29.     if not ok:
  30.         sys.exit(0)
  31.     walktree(fss.as_pathname(), change)
  32.     
  33. if __name__ == '__main__':
  34.     run(1)
  35.     
  36.     
  37.